#include <iostream>
using std::cout;
using std::endl;

int number = 10;
double division(double x,double y){
    if(y == 0){
        throw "Deivision by zero";
    }
    if(x == 0){
        throw 4.8;
    }
    return x/y;
}

void test0(){
    try{
        //如果函数执行的时候抛出了一个异常问题
        //后面的代码便不会继续执行了
        //跳转到了catch代码块中
        //catch执行完毕之后，继续向下执行
        //cout << division(9,0) << endl;
        //cout << division(0,100) << endl;
        cout << division(1000,100) << endl;
        cout << "try代码执行完毕" << endl;
    }catch(const char * msg){ //catch的小括号里是类型
        cout << "hello," << msg << endl;
    }catch(double x){
        cout << x << endl;
        cout << "please change a num!" << endl;
    }
    cout << "over" << endl;
}


int main()
{
    test0();
    return 0;
}

